using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Order.Dto;
using JTZY.Model.Order;
using JTZY.Service.Order.IOrderService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2025-02-16
namespace JTZY.Admin.WebApi.Controllers.Order
{
    /// <summary>
    /// 退款单表
    /// </summary>
    [Verify]
    [Route("order/Corecmsbillrefund")]
    public class CorecmsbillrefundController : BaseController
    {
        /// <summary>
        /// 退款单表接口
        /// </summary>
        private readonly ICorecmsbillrefundService _CorecmsbillrefundService;

        public CorecmsbillrefundController(ICorecmsbillrefundService CorecmsbillrefundService)
        {
            _CorecmsbillrefundService = CorecmsbillrefundService;
        }

        /// <summary>
        /// 查询退款单表列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "corecmsbillrefund:list")]
        public IActionResult QueryCorecmsbillrefund([FromQuery] CorecmsbillrefundQueryDto parm)
        {
            var response = _CorecmsbillrefundService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询退款单表详情
        /// </summary>
        /// <param name="RefundId"></param>
        /// <returns></returns>
        [HttpGet("{RefundId}")]
        [ActionPermissionFilter(Permission = "corecmsbillrefund:query")]
        public IActionResult GetCorecmsbillrefund(string RefundId)
        {
            var response = _CorecmsbillrefundService.GetInfo(RefundId);
            
            var info = response.Adapt<CorecmsbillrefundDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加退款单表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "corecmsbillrefund:add")]
        [Log(Title = "退款单表", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCorecmsbillrefund([FromBody] CorecmsbillrefundDto parm)
        {
            var modal = parm.Adapt<Corecmsbillrefund>().ToCreate(HttpContext);

            var response = _CorecmsbillrefundService.AddCorecmsbillrefund(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新退款单表
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "corecmsbillrefund:edit")]
        [Log(Title = "退款单表", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCorecmsbillrefund([FromBody] CorecmsbillrefundDto parm)
        {
            var modal = parm.Adapt<Corecmsbillrefund>().ToUpdate(HttpContext);
            var response = _CorecmsbillrefundService.UpdateCorecmsbillrefund(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除退款单表
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "corecmsbillrefund:delete")]
        [Log(Title = "退款单表", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCorecmsbillrefund([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<string>(ids);

            return ToResponse(_CorecmsbillrefundService.Delete(idArr));
        }

    }
}